package gui;

import java.awt.Image;
import java.awt.Toolkit;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Sequencer;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SpringLayout;


public class AproposUI extends JFrame {

	public AproposUI() {
		JLabel label = new JLabel();
		label.setLayout(new SpringLayout());
		setSize(200,400);
		setResizable(false);
		setTitle("À propos");
		ImageIcon image = new ImageIcon();
		try {
			URL url;
			url = new URL("http://i61.servimg.com/u/f61/14/91/67/46/logo210.jpg");
			image = new ImageIcon(Toolkit.getDefaultToolkit().getImage(url).getScaledInstance(200,200,Image.SCALE_DEFAULT));
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		JLabel toto = new JLabel();
		toto.setIcon(image);
		label.add (toto);
		label.add (new JLabel ("         © Tea'm Time          "));
		label.add (new JLabel ("   Nicolas AUBOIN, Radim BADSI, "));
		label.add (new JLabel ("    Célia BIGUZZI, Kévin CHAPON, "));
		label.add (new JLabel ("       Fanny FERLET, Sha LIU,     "));
		label.add (new JLabel (" Julien PARIS, Capucine ROLLAND"));
		
		// Lay out the panel.
		SpringUtilities.makeCompactGrid(label, 6, 1, 0, 0, 6, 6);
		add(label);
		
		playMidi();
		
	}
	
	void playMidi() {
		File midiFile = new File("champions.mid");
		Sequencer sequencer;
		try {
			sequencer = MidiSystem.getSequencer();
			try {
				sequencer.setSequence(MidiSystem.getSequence(midiFile));
			} catch (InvalidMidiDataException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			sequencer.open();
			sequencer.start();
		} catch (MidiUnavailableException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}


	}
}
